package common;

import java.security.Key;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import javax.crypto.spec.SecretKeySpec;
import javax.xml.bind.DatatypeConverter;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;

public class JwtToken1 {
	public static String createToken() throws Exception{  
        Map<String, Object> map = new HashMap<String, Object>();  
        map.put("alg", "HS256");  
        map.put("typ", "JWT");  
        String token = JWT.create()  
                .withHeader(map)//header  
                .withClaim("name", "zwz")//payload  
                .withClaim("age", "18")  
                .sign(Algorithm.HMAC256("secret"));//加密  
        return token;  
    }  
	
	public static void main(String[] args) throws Exception {
		System.out.println(createToken());
	}
}
